home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / PROBLEMS / DOC / APP_WRITING next >
Text File  |  1992-06-21  |  17KB  |  418 lines

  1. Article 20 of comp.sources.acorn:
  2. Path: news.uni-stuttgart.de!Sirius.dfn.de!darwin.sura.net!wupost!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!jwil1
  3. Newsgroups: comp.sources.acorn
  4. Subject: The CSA App. Writers' Guide
  5. Message-ID: <1992Jun22.004155.17060@cs.aukuni.ac.nz>
  6. From: jwil1@cs.aukuni.ac.nz (TMOTA)
  7. Date: Mon, 22 Jun 1992 00:41:55 GMT
  8. Sender: jwil1@cs.aukuni.ac.nz (TMOTA)
  9. Organization: Computer Science Dept. University of Auckland
  10. Approved: cba@acorn.co.nz
  11. Lines: 403
  12.  
  13. The comp.sys.acorn Application Writer's Guide
  14. =============================================
  15.  
  16. This guide contains a lot of small hints from some of the gurus on 
  17. comp.sys.acorn. Most of them are pet hates - things that many 
  18. applications do that really annoy us. When writing applications, 
  19. please read through this list and check that your application 
  20. conforms to as many as possible of the items...
  21.  
  22. Many of these things might seem complicated at first, but they are 
  23. all very simple when you know what you are doing. All the 
  24. information needed can be found in the Programmers Reference 
  25. Manuals, or ask someone for some help!
  26.  
  27. This guide is kept by Jason Williams (jwil1@cs.aukuni.ac.nz), so
  28. please email any new suggestions for the guide to him. Any suggestions
  29. made on comp.sys.acorn should also be caught and included...
  30.  
  31.  
  32. "Public Domain"
  33. ===============
  34.  
  35. Public Domain means that everything in the application can be 
  36. used, changed, copied, etc. exactly as the user wishes. They can 
  37. even include portions of your application in their own (commercial)
  38. programs if they so wish.
  39.  
  40. Public Domain and Copyright are MUTUALLY EXCLUSIVE!
  41.  
  42. If you wish to place distribution conditions on your software, then 
  43. call it FREEware, and clearly state your conditions. Using this term, 
  44. you can also claim copyright on your software.
  45.  
  46. Legally, if you choose to use the term 'Public Domain', then you 
  47. don't have a leg to stand on, even if you stated that the software 
  48. was copyright, etc.
  49.  
  50.  
  51. Icon sprites/Screen modes
  52. =========================
  53.  
  54. Never include additional sprites (eg your own definitions of 
  55. system sprites) in the !Sprites file of your application.
  56.  
  57. Always include small icons as well as large ones in your sprite 
  58. files.
  59. Regardless of how hard the things are to design, you can always 
  60. do a better job than the automatic scaling of the large icons.
  61.  
  62. Always include a !Sprites22 (Mode 20) and !Sprites23 (Mode 23) 
  63. file as well as !Sprites (Mode 12) - even if you can't display 
  64. multisync sprites on your monitor, you can still create & edit
  65. them provided you use at least 2x magnification.
  66.  
  67. Make sure all your sprites have a core RISC OS 2 ROM mode 
  68. number (Sprites should be defined in mode 0, 12, 20, or 23).
  69. Be very careful about this if you start using screen snapshots to 
  70. help you design sprites. Similarly make sure you remove the 
  71. sprite's palette after doing a screen shot to create an icon.
  72.  
  73. Always try your !Sprites in MODEs 8 and 0 (4 and 2 colour) to make sure
  74. they don't disappear. Careful choice of colours will ensure they don't
  75. Similarly aways try !Sprites22 in MODEs 19 and 18 as well as Mode 20. Your
  76. !Sprites23 should look similar to your !Sprites22 in MODE 18, but some
  77. difference is reasonable since you can hand stipple !Sprites23 as they are
  78. for monochrome display only.
  79.  
  80. RUN your program in ALL screen modes you can lay your hands on. Do
  81. all your icons dissapear due to colourtransing in mode 0? Do your
  82. 256-colour icons go SPLAT in mode 12?
  83.  
  84. Does your code fall over in mode 66, 78, 120? (Not checking the size
  85. of the screen is a very common fault. DO NOT assume that the 
  86. screen other people are using is identical to the one you use!
  87.  
  88. Get the size of the iconbar icon RIGHT! If in the program you declare
  89. the iconbar icon bounds as 0,0;68,68 then make the sprite you use
  90. 34x17 in mode 12/0 or 34x34 in mode 20/23!
  91. Try 'dabbing' at the edges of your icons with a window or menu 
  92. and see if you can cause bits of the icon to be 'rubbed out' and not 
  93. correctly redrawn.
  94.  
  95. Info windows like those used by BASS are pretty with all their 
  96. sprites, but how much memory does this take? Place these sprites 
  97. into a file we can edit (don't compact them in with the 
  98. !RunImage), and preferably give an option that stops unnecessary 
  99. sprites being loaded/displayed.
  100.  
  101.  
  102. !Boot & !Run files
  103. ==================
  104.  
  105. Only include a !Boot file if it is absolutely necessary. Remember 
  106. that other users may not appreciate an unnecessary !Boot file,
  107. particularly if they are Econet users.
  108.  
  109. If a !Boot file is missing, then the equivalent of
  110.   IconSprites <Obey$Dir>.!Sprites
  111. will be done automatically for you.
  112.  
  113. ALWAYS put an IconSprites <Obey$Dir>.!Sprites into your !Run file.
  114. If the application is launched with !Menon or similar, the sprites 
  115. will not have been loaded by your app. dir. being 'seen'.
  116.  
  117. Suggestion: rather than having a !Run file which goes "Obey <foo$Dir>.
  118. !Boot", include the contents of the !Boot file in line in the !Run file.
  119. This way the application starts up quicker over Econet, as the 
  120. !Boot file doesn't have to be loaded.
  121.  
  122. Never have anything (not even blank lines) after the "Run <foo$Dir>.
  123. !RunImage" in your !Run file, otherwise the !Run file stays open 
  124. while your application is running and only gets closed when it 
  125. quits.
  126.  
  127. Don't make your program auto-run in a !Boot file. If you want people
  128. to have the option of this, give them a file they can rename to 
  129. !boot...
  130.  
  131.  
  132. Help files
  133. ==========
  134.  
  135. Always include a !Help file. This should be a plain text file, and
  136. never one of these !Help applications which are springing up.
  137.  
  138. IF you MUST use a non-text !Help file, then use an Obey file that 
  139. checks if the application your Helpfile needs is loaded, and reverts 
  140. to just RUNning the text version of the help if the special 
  141. application is not found.
  142.  
  143. Always call the help file '!Help', not 'ReadMe' or other names. This
  144. allows help to be offered on the filer menu.
  145.  
  146. Always include your name in the !Help file, as well as the application.
  147. You don't have to include your address, but without a name, it can be
  148. very difficult to identify pieces of software.
  149. DON'T include your name if you are re-releasing somebody else's 
  150. work - passing off someone else's program as your own is bad, 
  151. and could get you into a lot of trouble.
  152.  
  153. Always credit other people for any help/code they supplied you 
  154. for your application.
  155.  
  156. A nice option is to check if your help file exists from within the 
  157. application, and offer a 'help' option on your main menu, which 
  158. simply RUNs the text file...
  159.  
  160. Always include an indication of the legal status of the software, 
  161. and whether or not it may be freely distributed.
  162.  
  163.  
  164. Other files/resources
  165. =====================
  166.  
  167. Don't put lots of subdirectories inside the application if it can be 
  168. helped. People with hard drives typically lose 14k for each 
  169. directory you bung in, which often wastes more space than the 
  170. total size of a small PD application... :-(
  171.  
  172. Get all your resources with <App$Dir>.Name, where Name is the filename
  173. of the resource, and App is the name of your application. Set this
  174. variable (*Set App$Dir <Obey$Dir>) in your !Run file.
  175.   DON'T use <Obey$Dir>.Name inside your main program!
  176.   DON'T use "$.!app.file" or "adfs::Mydisc.$.!app.file"
  177. -Even though this is convenient, it is bad form, and may cause 
  178. problems for anyone who adds functionality to your program 
  179. later. Do it right the first time!
  180.  
  181. Alternatively do "*Set App$Path <Obey$Dir>." (note the trailing 
  182. period character) and reference files as App:Name. This only 
  183. works for reading though.
  184. RISC OS 3 applications tend to have both a $Dir and a $Path. The 
  185. path is used for reading reasource files, so they can be in several 
  186. places (and indeed some of them are - see Alarm$Path). $Dir is 
  187. used for writing configuration files etc.
  188.  
  189. Preferably, use a SEPARATE variable for your config. files, so that 
  190. someone else can easily move your config. data to a central place 
  191. and then rename your variable to point there instead. This can 
  192. allow your program to be run from read-only filing systems (e.g. 
  193. on econet, etc)
  194.  
  195. Always use <Wimp$Scrap> and <Wimp$ScrapDir> for storing temporary files
  196. in. Never store them inside your own application's directory. In this way
  197. the user is free to put temporary files where he wants them, rather than
  198. ending up with them spread over 4 different floppy discs with attendant
  199. unecessary disc swapping. The disc with <Wimp$ScrapDir> on it is probably
  200. already in the drive.
  201. On RISC OS 2 you need to be careful about <Wimp$ScrapDir> as it 
  202. doesn't always exist. It is suggested that you supply a !Scrap 
  203. application with your software if you make use of <Wimp$ScrapDir>
  204.  
  205.  
  206. Windows
  207. =======
  208.  
  209. Even if you only have an info window, make sure you process 
  210. OPENWINDOW requests, or your windows won't be movable.
  211.  
  212. Info windows that go away when you move the pointer out of them are
  213. *incredibly* annoying! Likewise, Info windows that limit the 
  214. pointer (BASS!) are a hassle. (Especially in Protracker where the 
  215. limit is a window *behind* the one you are looking at... I *hate* 
  216. that!)
  217.  
  218. Always open windows as defined in the templates file. Reposition 
  219. them if you like, but don't change their size! Some people have 
  220. bigger screen modes than you and they like to have bigger 
  221. windows when they are first opened!
  222.  
  223. Open windows centered in the *current* screen mode, or over a 
  224. parent window. I hate windows appearing as squitty little things 
  225. in the corner of large multisync modes. I also hate windows 
  226. appearing off the top/side of mode 12...
  227.  
  228. Preferably, check the window position when things happen - if 
  229. the window is fullsized, or if the screen mode changes, check if 
  230. you need to 'bump' the window back onto the screen. At least the 
  231. titlebar should be available so it can be dragged back onto the 
  232. screen! Preferably also allow your windows to be dragged off the 
  233. screen (This means if fullsize is clicked, you must ensure that the 
  234. window doesn't get bigger than the current screen mode)
  235.  
  236.  
  237. Window Templates
  238. ================
  239.  
  240. If you get memory for templates, DON'T trim down the allocated 
  241. memory to the exact byte needed for *your* templates. Add a few 
  242. hundred bytes so we can alter/add to templates without your 
  243. program crashing. This is especially a good idea when you are 
  244. only using half of the WIMPSLOT memory anyway... (Acorn, do 
  245. you hear me? ;-)
  246. If this is a big problem and you are supplying source, give a 
  247. constant./variable that is easily found to change the allocation.
  248.  
  249. In RISC OS 3.00, there is a call to tell you how much memory is 
  250. needed for your Templates to be loaded.
  251.  
  252. 3-d 'plinthy' windows look nice. Some people don't think so, 
  253. though, and it would be very nice if you supply two sets of 
  254. templates, one for 3-d and one for 2-d icons.
  255.  
  256. Note that 'Interface' is incompatible with RISC OS 3.00's way of 
  257. redrawing 3-d icons, so your application will look really crappy in 
  258. RISC OS 3.00.
  259.  
  260.  
  261. Menus
  262. =====
  263.  
  264. Put your menu 96 OS units above the menu bar (40% of PD apps. fail
  265. this one, and it is a right pain!). The TOP menu item of your iconbar
  266. menu should be INFO, and the bottom one should be QUIT.
  267. This calculation is:
  268.   y = 96 + (number_of_items * 44) + (number_of_dotted_lines * 24)
  269.  
  270. Menu items should be 44 OS units high, and the item gap should be 0.
  271. Menu items should be left justified (DON'T center them!)
  272.  
  273. Don't put dangerous items next to innocuous one ins menus. A very bad
  274. example of brain-dead design lies over your floppy :0 drive icon -
  275. notice how dismount, format, verify, are all bunched together?
  276. How many times have *you* hit format instead of dismount?
  277.  
  278.  
  279. Fonts
  280. =====
  281.  
  282. Go to the command-line. Type *FX25 <return>. Go back to the desktop.
  283. Do all of the symbols used in your program look right still? Good.
  284. (If you have really been screwing around in the system, you may 
  285. need a *alphabet bfont as well)
  286.  
  287. If using outline fonts, AT LEAST put an easy to find option or 
  288. variable that can be set to allocate enough room for the font 
  289. menu... most people seem to make their programs to use their 5 
  290. fonts, and don't realise some people have around 300 fonts on 
  291. their hard drives! It is in fact possible to count the number of 
  292. available fonts, and allocate enough memory to read them all.
  293.  
  294. If replacing BFONT with an outline font, remember these points:
  295. * 14 point is usually about the best size - not too big to fit, roughly
  296.   the same size as BFONT, and not so small as to look 'grubby' in low
  297.   res modes (12, 15)
  298. * Use ONE font (family) consistently throughout the app.
  299. * Use ONE (or maybe 2) font size consistently throughout.
  300.   (More sizes means heavy font cache usage - thrashing off disc and
  301.    more memory needed, which are bad things)
  302. * Use Trinity, Homerton, (or Porterhouse) unless you are providing the
  303.   font with the application- these fonts are available to everyone, and
  304.   the first two are in ROM in RO3.
  305. * Give an OPTION to use BFONT.
  306. * Preferably check that there is at least 16k allocated to the font cache
  307.   and drop back to BFONT if this is not the case
  308.  
  309.  
  310. Filing systems
  311. ==============
  312.  
  313. Don't leave files open.
  314. Don't close open files with CLOSE#0 !!!
  315.  
  316. DON'T assume anything about the FS you are run from.
  317. Or the Drive number.
  318. Don't even assume that you can write to the Filing System if it can 
  319. be helped.
  320.  
  321. Don't set the CSD or library or alter any FS paths. Don't alter the 
  322. current filing system.
  323.  
  324. If doing file operations in C, try using setvbuf. I found in 
  325. CBAdecode that a 150% speed improvement resulted off floppies 
  326. (using 16k buffers in place of OS 4k buffers), and seeking was 
  327. drastically reduced on my hard drive.
  328.  
  329.  
  330. Configuration
  331. =============
  332.  
  333. If your program alters the machine in any way (eg redefines system beep,
  334. or changes mouse pointer), make sure that they are restored when it
  335. finally terminates. Be especially careful to make this work when 
  336. the program crashes! (And don't assume that it won't crash!)
  337.  
  338. Don't use *CONFIGURE commands in your applications. They are 
  339. NOT needed for anything you should be doing.
  340.  
  341. Don't *UNPLUG modules you want to kill- *RMKILL them.
  342. Never include a *RMCLEAR command in your programs.
  343.  
  344. Make sure that your program doesn't use any unusual modules or screen
  345. modes, unless they are included with the application.
  346.  
  347. If you need to RMEnsure modules from !System, try to check for the
  348. earliest possible version which will work with your software.
  349.  
  350. If your program uses a module, make sure that if the module is RMCLEARed,
  351. the application will quit cleanly, rather than going into an infinite
  352. loop.
  353.  
  354. Make sure that the memory you ask for in the WimpSlot 
  355. command in your !Run file is equal to the actual amount displayed 
  356. in the task manager window when the program starts running. 4 
  357. Megabyte machine will give you 32kB of memory even if you only 
  358. ask for 8kB, but a 1MB machine will only give you 8kB! This 
  359. causes lots of programs to fail to run on 1/2MB machines.
  360.  
  361. Bearing the above in mind, trim down the WIMPSLOT size to a 
  362. safe minimum.
  363.  
  364.  
  365. Miscellanea
  366. ===========
  367.  
  368. CTRL-Break your machine and then hold down SHIFT so it doesn't 
  369. autoboot. THis should give you a reasonably 'clean' machine, with 
  370. no strange modules, screen modes, etc. Does your program still 
  371. run fine on this 'bare' machine?
  372.  
  373. If a program will not allow users to return to the desktop, display a
  374. warning giving them the chance to return to the desktop before the
  375. program starts running.
  376.  
  377. Use % in front of any *commands you use, and specify ALL options
  378. e.g. "%wipe file ~v ~c r f"
  379. This should get around aliases that do unexpected things and odd
  380.  wipe options configurations that you didn't expect.
  381.  
  382. Get a program that protects zero page and run it. Now run your
  383. application. If you get "Abort on data transfer" errors, you are
  384. writing to places you shouldn't.
  385.  
  386. When files are saved to you from another app., you first get a 
  387. DataSave message including a suggested leafname. REMEMBER THIS LEAFNAME. When
  388. you subsequently get a <Wimp$Scrap> or similar transfer, you can then
  389. use the remembered leafname as the filename instead of <Wimp$Scrap>.
  390. I *hate* the way Edit gets this wrong.
  391.  
  392. MASK OUT NULL POLLS while you aren't using them!
  393. If you need nulls, then use Wimp_PollIdle.
  394. Clocks only need updating every second or so... If only minutes 
  395. are displayed then an update every 10 seconds is close enough. 
  396. Thus, use PollIdle to give you 1 null poll every 10 secs, and save a 
  397. lot of desktop bandwidth to make drags, etc. smoother.
  398.  
  399. When doing long operations, multitask in the background. This is 
  400. not difficult to do, and doesn't affect the speed of your program 
  401. much.
  402. (I found that with 20cs timeslices for processing, there was not
  403. a noticable (to the centisecond, at least) time difference in
  404. processing that took 90 or so seconds... 5 polls in a second just
  405. don't take a noticable time.
  406. This allows people to abort things quickly and allow them to do 
  407. low-bandwidth operations such as editing textfiles while doing 
  408. stuff in the background.
  409.  
  410. Oh, and while multitasking, don't use the hourglass!
  411.  
  412. -- 
  413. _________________  "I'd like to answer this question in two ways:
  414.   /____ _ _/_ __       First in my normal voice, and then
  415.  // / //_//_ /_/       in a silly, high-pitched whine." (Monty Python)
  416.  
  417.  
  418.